package com.yy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;



@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {

    public static String myTableName;

    public static void myTableName(String s) {
        myTableName=s;
    }


    /**
     * 分页插件
     */
   /* @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }*/
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
       /* DynamicTableNameParser dynamicTableNameParser = new DynamicTableNameParser();
        HashMap<String, ITableNameHandler> handlerHashMap=new HashMap<>();
        handlerHashMap.put("", new ITableNameHandler() {
            @Override
            public String dynamicTableName(MetaObject metaObject, String sql, String tableName) {
                return myTableName;
            }
        });
        dynamicTableNameParser.setTableNameHandlerMap(handlerHashMap);
        paginationInterceptor.setSqlParserList(Collections.singletonList(dynamicTableNameParser));*/
        return paginationInterceptor;
    }
}
